package com.clientes;

import java.util.List;

import com.eventos.LugarOverlay;
import com.eventos.RutaOverlay;
import com.eventssmartphone.R;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
import com.google.android.maps.Projection;


import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;


public class ActivityVerMapa extends MapActivity {
	  /** Called when the activity is first created. */
		MapView mapa;
	
        GeoPoint loc;
        Point centro;
        Projection projection;
        String nombre;
        String ubicacion;
        double x;
        double y;
        private MapController controlMapa = null;
		
	    @Override
	    public void onCreate(Bundle savedInstanceState) {
	        
	    	Log.i("mapita","entre");
	    	super.onCreate(savedInstanceState);
	        setContentView(R.layout.ev_verruta);
	        mapa=(MapView) findViewById(R.id.idmapa);
	        controlMapa = mapa.getController();
	       
	        
	        Bundle b = getIntent().getExtras();
	        nombre = b.getString("nombre");
	       ubicacion = b.getString("direccion");
	       x=b.getDouble("x");
	       y=b.getDouble("y");
	        List<Overlay> mapOverlays = mapa.getOverlays();
	        Drawable drawable = this.getResources().getDrawable(R.drawable.map_marker);
	        LugarOverlay itemizedoverlay = new LugarOverlay(drawable, this);
	        
	       
	        
	        loc = new GeoPoint((int)(x*1e6), (int)(y*1e6));
	        Projection projection = mapa.getProjection();
	        controlMapa.setCenter(loc);
	        centro = new Point();
	        projection.toPixels(loc, centro);
	      
	       //GeoPoint point = new GeoPoint(19240000,-99120000);
	        OverlayItem overlayitem = new OverlayItem(loc, nombre,ubicacion);
	        
	       itemizedoverlay.addOverlay(overlayitem);
	        mapOverlays.add(itemizedoverlay);
	        
	        
	        
	       
	        controlMapa.setZoom(14);
	        mapa.setBuiltInZoomControls(true);
	        
	      /*  Paint p = new Paint();
			p.setColor(Color.BLUE);
			Bitmap bm = BitmapFactory.decodeResource(
					mapa.getResources(), 
					R.drawable.icono_googlemaps);*/
			
			//canvas.drawBitmap(bm, centro.x - bm.getWidth(), 
				//	              centro.y - bm.getHeight(), p);
	        
	        
	        
	        //Toast toast = Toast.makeText(this,"Local", Toast.LENGTH_SHORT);
	        //toast.show();
	    }

		protected boolean isRouteDisplayed() {
			// TODO Auto-generated method stub
			return false;
		}
}
